#include<stdlib.h>
void InitExpTree(BTree &T,string str) 
{
   stack<BTree>s;
   stack<char>op;
   op.push('#'); 
   int i=0;
   while(str[i])
   {
      if(In(str[i])){
         switch(Precede(op.top(),str[i]))
         {
            case '<':
               op.push(str[i]);
               i++;
               break;
            case '=':
               op.pop();
               i++;
               break;
            case '>':
               T=new BTNode;
               T->data=op.top();
               T->rchild=s.top();
               s.pop();
               T->lchild=s.top();
               s.pop();
               s.push(T);
               op.pop();
               break;
         }
	  }	
      else{
         T=new BTNode;
         T->data=str[i++];
         T->lchild=T->rchild=NULL;
         s.push(T);
      }
   }
   while(op.top()!='#')
   {
      T=new BTNode;
      T->data=op.top();
      T->rchild=s.top();
      s.pop();
      if(!s.empty())
      {
         T->lchild=s.top();
         s.pop();
      }

      s.push(T);
      op.pop();
   }
   T=s.top();
}
double EvaluateExTree(BTree T)
{
   double sum=0,m,n;
   if(!T->lchild&&!T->rchild)
      return T->data-'0';
   m=EvaluateExTree(T->lchild);
   n=EvaluateExTree(T->rchild);
   switch(T->data)
   {
   case '+':
      return m+n;
      break;
   case '-': 
      return m-n;
      break;
   case '*':
      return m*n;
      break;
   case '/':
      if(n==0)
      {
         cout<<"divide 0 error!"<<endl;
         exit(0);
      }
      return m/n;
      break;
   }
}
